package com.alipay.util;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

//import net.sf.json.JSONObject;

public class PayCommonUtils {
	 private final static Logger logger=LoggerFactory.getLogger(PayCommonUtils.class);
	 //各种支付接口编码，alipay_create_direct、alipay_mobile_qrcode、alipay_batch_trans_noPwd、wxpay_create_direct、chinaPay
	 public static final String alipay_create_direct="alipay_create_direct";
	 public static final String alipay_pureGateway="alipay_pureGateway";
	 //支付宝即时到账接口，新协议的手续费0.8%    即时到账交易接口(create_direct_pay_by_user)：需取代原即时到账交易接口。费率统一改为单笔交易流量的0.8%；
	 public static final String alipay_create_direct_new="alipay_create_direct_new";
	 public static final String alipay_mobile_qrcode="alipay_mobile_qrcode";
	 public static final String aliwappay_mobile_create_direct="aliwappay_mobile_create_direct";
	 public static final String alipay_batch_trans_noPwd="alipay_batch_trans_noPwd";
	 public static final String alipay_BatchTransNoPwd_brokerage="ali_BatchTransNoPwd_brokerage";
	 public static final String wxpay_create_direct="wxpay_create_direct";
	 
	 public static final String jfbpay_BatchTrans_brokerage="jfbpay_BatchTrans_brokerage";
	 public static final String jfbpay_BatchTrans_brokerage_bank="jfbpay_BatchTrans_brokerage_bank";
	 public static final String jfbpay_create_direct="jfbpay_create_direct";
	 public static final String jfbpay_pureGateway="jfbpay_pureGateway";
	 //退款编码
	 public static final String ali_refund_fastpay_by_platform_nopwd="ali_refund_fastpay_by_platform_nopwd";
	 public static final String wx_refund="wx_refund";
	 //银联接口
	 public static final String chinaPay="chinaPay";
	 //支付宝即时到账接口，新协议的手续费0.8%    即时到账交易接口(create_direct_pay_by_user)：需取代原即时到账交易接口。费率统一改为单笔交易流量的0.8%；
	 public static final double alipay_create_direct_new_1 = 0.008;
	 //纯网关接口为网银支付接口，后续可酌情使用。费率统一为单笔交易流量的0.3%
	 public static final double alipay_pureGateway_1 = 0.003;
	 //支付手续费，最小单位0.01 ，四舍五入
	 //支付宝即时到账接口，0 - 60000元,手续费1.2%
	 public static final double alipay_create_direct_1 = 0.012;
	 //支付宝即时到账接口，60000 - 500000元,手续费1% 
	 public static final double alipay_create_direct_2 = 0.01;
	 //支付宝即时到账接口，500000 - 1000000元,手续费0.9% 
	 public static final double alipay_create_direct_3 = 0.009;
	 //支付宝即时到账接口，1000000 - 2000000元,手续费0.8% 
	 public static final double alipay_create_direct_4 = 0.008;
	 //支付宝即时到账接口，2000000元以上,手续费0.7% 
	 public static final double alipay_create_direct_5 = 0.007;
	 //支付宝扫码支付接口，0-10000元,手续费2.5%
	 public static final double alipay_mobile_qrcode_1 = 0.025;
	 //支付宝扫码支付接口，10000-100000元,手续费2.4%
	 public static final double alipay_mobile_qrcode_2 = 0.024;
	 //支付宝扫码支付接口，100000-1000000元,手续费2.2%
	 public static final double alipay_mobile_qrcode_3 = 0.022;
	 //支付宝扫码支付接口，1000000元以上,手续费2.0%
	 public static final double alipay_mobile_qrcode_4 = 0.02;
	 
	 //手机网页即时到账接口：需取代原手机网页即时到账接口。费率统一改为单笔交易流量的1%；
	 public static final double aliwappay_mobile_create_direct_1 = 0.01;
	 
	 //支付宝无密批量付款到支付宝账支付接口，0 - 20000元(单笔交易额),1.00元,按每笔交易来进行计算
	 public static final double alipay_batch_trans_noPwd_1 = 1.00;
	 //支付宝无密批量付款到支付宝账支付接口，20000 - 50000元(单笔交易额),3.00元,按每笔交易来进行计算
	 public static final double alipay_batch_trans_noPwd_2 = 3.00;
	 //支付宝无密批量付款到支付宝账支付接口，50000元以上(单笔交易额),5.00元,按每笔交易来进行计算
	 public static final double alipay_batch_trans_noPwd_3 = 5.00;
	 //支付宝微信财付通接口，统一资费，最小单位0.01 ，四舍五入，都按0.6%
	 public static final double wxpay_create_direct_1 = 0.006;
	 //澄美账号，佣金提现，手续费按单笔0.5%算，四舍五入
	 public static final double alipay_BatchTransNoPwd_brokerage_1 = 0.005;
	 //银联接口，后续增加
	 public static final double chinaPay_1 = 0;
	 //四舍五入，保留两位小数
	 public static final String scale= "%.2f";
	 
	 private static String errorException="温馨提示：系统异常，请联系客服解决！";
	 
	 public static String SUCCESS="SUCCESS";
	 public static String FAIL="FAIL";
	 public static String notify_url="http://123.138.182.62:15381/";
	 public static String ALI_NOTIFY_BASE_key="ALI_NOTIFY_BASE_URL";
	 //支付成功，调广度页面配置
	 public static String alipay_Uni_guangdu_returnSuccess="ALIPAY_UNI_GUANGDU_RETURNSUCCESS";
	 public static String alipay_Uni_guangdu_returnfail="ALIPAY_UNI_GUANGDU_RETURNFAIL";
	 public static String alipay_Uni_guangdu_notify="ALIPAY_UNI_GUANGDU_NOTIFY";
	 //提现操作，返回编码
	 public static String retcode_success="99999999";
	 public static String retcode_fail="44444444";
	 
	 //支付状态
	 public static String pay_code_success="00";
	 public static String pay_code_fail="01";

	 public static String outersystem_key="outersystem_J4V5uSSRLg6kHRmo";
	 public static String qjwd="qjwd";

	 //集付宝返回码
	 public static Map<String,String>  JfbResultCode(){
			HashMap<String,String> errorMap= new HashMap<String,String>();
			errorMap.put("000000", "成功");
			errorMap.put("S60001", "系统异常");
			errorMap.put("D22209", "该订单已支付，请不要重复提交");
			errorMap.put("D22401", "退货金额大于可退货金额");
			errorMap.put("D22404", "退款金额大于订单金额");
			errorMap.put("D22208", "订单状态异常");
			errorMap.put("D23190", "退款日期超过最大有效期");
			errorMap.put("D75082", "查询订单信息出错");
			errorMap.put("E25856", "此订单正在退款中");
			errorMap.put("E22491", "快捷支付超时");
			return errorMap;
		}
	 
	//退款错误编码映射关系
	public static Map<String,String>  Refund_errorMap(){
		HashMap<String,String> errorMap= new HashMap<String,String>();
		errorMap.put("BATCH_NUM_ERROR", "传入的总笔数格式错误");
		errorMap.put("SINGLE_DETAIL_DATA_EXCEED_LIMIT", "单笔退款明细超出限制");
		errorMap.put("TRADE_STATUS_ERROR", "交易状态不允许退款");
		errorMap.put("RESULT_AMOUNT_NOT_VALID", "退收费、退分润或者退款的金额错误");
		errorMap.put("TRADE_NOT_EXISTS", "交易不存在");
		errorMap.put("TRADE_HAS_CLOSED", "交易已关闭，不允许退款");
		errorMap.put("TRADE_HAS_FINISHED", "交易已结束，不允许退款");
		errorMap.put("REFUND_CHARGE_FEE_GREATER_THAN_LIMIT", "退收费金额超过限制");
		errorMap.put("REFUND_TRADE_FEE_ERROR", "退交易金额不合法");
		errorMap.put("SELLER_STATUS_NOT_ALLOW", "卖家状态不正常");
		errorMap.put("TXN_RESULT_ACCOUNT_STATUS_NOT_VALID", "卖家账户状态无效或被冻结");
		errorMap.put("TXN_RESULT_ACCOUNT_BALANCE_NOT_ENOUGH", "卖家账户余额不足");
		errorMap.put("REFUND_SUBTRADE_FEE_ERROR", "退款交易金额不合法");
		errorMap.put("NANHANG_REFUND_CHARGE_AMOUNT_ERROR", "退票面价金额不合法");
		errorMap.put("REFUND_AMOUNT_NOT_VALID", "退款金额不合法");
		errorMap.put("TRADE_PRODUCT_TYPE_NOT_ALLOW_REFUND", "交易类型不允许退交易");
		errorMap.put("RESULT_FACE_AMOUNT_NOT_VALID", "退款票面价不能大于支付票面价");
		errorMap.put("REFUND_CHARGE_FEE_ERROR", "退收费金额不合法");
		errorMap.put("RESULT_AMOUNT_NOT_VALID", "退收费金额错误");
		errorMap.put("REASON_TRADE_REFUND_FEE_ERR", "退款金额错误");
		errorMap.put("TXN_RESULT_ACCOUNT_BALANCE_NOT_ENOUGH", "账户余额不足");
		return errorMap;
	}
	
	//退款错误编码映射关系
		public static Map<String,String>  wx_Refund_errorMap(){
			HashMap<String,String> errorMap= new HashMap<String,String>();
			errorMap.put("1", "未确定，需要商户原退款单号重新发起");
			errorMap.put("2", "未确定，需要商户原退款单号重新发起");
			errorMap.put("3", "退款失败");
			errorMap.put("5", "退款失败");
			errorMap.put("6", "退款失败");
			errorMap.put("8", "退款处理中");
			errorMap.put("9", "退款处理中");
			errorMap.put("11", "退款处理中");
			errorMap.put("7", "转入代发，退款到银行发现用户的卡作废或者冻结了，导致原路退款银行卡失败，资金回流到商户的现金帐号，需要商户人工干预，通过线下或者财付通转账的方式进行退款");
			return errorMap;
		}
		
		
		//批量付款到支付宝账户无密接口batch_trans_notify_no_pwd,错误编码映射关系
		public static Map<String,String>  batch_trans_errorMap(){
			HashMap<String,String> errorMap= new HashMap<String,String>();
			errorMap.put("ACCOUNT_NOT_MATCH", "文件信息和账户信息不匹配或付款账户非正常状态");
			errorMap.put("USER_NOT_EXIST", "用户不存在");
			errorMap.put("USER_BLOCKED", "用户被冻结");
			errorMap.put("batchFeesIsNull", "总金额为空");
			errorMap.put("detailDataIsNull", "单笔数据集为空");
			errorMap.put("BATCH_NO_NOT_UNIQUE", "商户提交的该批次已存在");
			errorMap.put("baccountNameIsNull", "账户名称为空	");
			errorMap.put("PAY_EMAIL_NAME_NOT_MATCH", "付款人email账号与姓名不匹配");
			errorMap.put("batchNoIsNull", "批次号为空");
			errorMap.put("MAX_SINGLE_FEE", "单笔最大金额超出限制");
			errorMap.put("NOT_ENOUGH_AMOUNT", "付款账号余额不足");
			errorMap.put("MAX_SINGLE_FEE_FOR_CERT", "都是认证商家并超过限额");
			errorMap.put("TRANS_NO_NOT_UNIQUE", "商户批次流水号不唯一");
			errorMap.put("partnerORPayEmailError", "合作伙伴Email和付款人Email不一致");
			errorMap.put("PROFILE_BATCH_PAYMENT", "付款方没有批量付款权限");
			errorMap.put("ILLEGAL_SIGN", "签名不正确");
			errorMap.put("ILLEGAL_DYN_MD5_KEY", "动态密钥信息错误");
			errorMap.put("ILLEGAL_ENCRYPT", "加密不正确");
			errorMap.put("ILLEGAL_ARGUMENT", "参数不正确");
			errorMap.put("ILLEGAL_USER", "用户ID不正确");
			errorMap.put("ILLEGAL_PARTNER", "合作伙伴信息不正确");
			errorMap.put("ILLEGAL_EXTERFACE", "接口配置不正确");
			errorMap.put("ILLEGAL_PARTNER_EXTERFACE", "合作伙伴接口信息不正确");
			errorMap.put("ILLEGAL_CHARSET", "字符集不合法");
			errorMap.put("ILLEGAL_CLIENT_IP", "客户端IP地址无权访问服务");
			errorMap.put("SESSION_TIMEOUT", "session超时");
			errorMap.put("ILLEGAL_TARGET_SERVICE", "错误的target_service");
			errorMap.put("EXTERFACE_IS_CLOSED", "接口已关闭");
			errorMap.put("BATCH_NO_ERROR", "文件批次号错误");
			errorMap.put("ACCOUN_NAME_NOT_MATCH", "支付宝账号名称不正确");
			errorMap.put("RECEIVE_USER_NOT_EXIST", "支付宝账号不存在");
			errorMap.put("TRANSFER_AMOUNT_NOT_ENOUGH", "付款账号余额不足");
			errorMap.put("ERROR_OTHER_NOT_REALNAMED", "支付宝账号没有进行实名制验证");
			errorMap.put("ILLEGAL_USER_STATUS", "支付宝账号状态有误");
			return errorMap;
		}
		
	
	//比较两个数大小,第一位数大于第二位数 大于返回1，等于返回0，小于返回-1
	public static int compare(BigDecimal val1, int val2) {
		   BigDecimal b_val2 = new BigDecimal(val2); 
		   int result =9;  
		   if (val1.compareTo(b_val2) < 0) {  
		       result = -1;  
		   }  
		   if (val1.compareTo(b_val2) == 0) {  
		       result = 0;  
		    }  
		    if (val1.compareTo(b_val2) > 0) {  
		        result = 1;  
		    }
		    b_val2=null;
		    return result;  
		}  
	
	  //加法
	  public   static   double   add(double   v1,double   v2){   
          BigDecimal   b1   =   new   BigDecimal(Double.toString(v1));  
           BigDecimal   b2   =   new   BigDecimal(Double.toString(v2));  
           return   b1.add(b2).doubleValue();   
	  }   
	  //减法
	    public   static   double   sub(double   v1,double   v2){   
            BigDecimal   b1   =   new   BigDecimal(Double.toString(v1));  
             BigDecimal   b2   =   new   BigDecimal(Double.toString(v2));  
             return   b1.subtract(b2).doubleValue();   
	    } 
	  
	  //乘法
	  public static double mul(double d1, double d2)
	    {        // 进行乘法运算 
	         BigDecimal b1 = new BigDecimal(d1); 
	         BigDecimal b2 = new BigDecimal(d2); 
	        return b1.multiply(b2).doubleValue(); 
	     }
	  /**  
	  * 提供（相对）精确的除法运算。当发生除不尽的情况时，由scale参数指  
	  * 定精度，以后的数字四舍五入。  
	  * @param v1 被除数  
	  * @param v2 除数  
	  * @param scale 表示表示需要精确到小数点以后几位。  
	  * @return 两个参数的商  
	  */  
	  public static double div(double v1,int v2,int scale){   
	  if(scale<0){   
	  throw new IllegalArgumentException(   
	  "The scale must be a positive integer or zero");   
	  }   
	  BigDecimal b1 = new BigDecimal(Double.toString(v1));   
	  BigDecimal b2 = new BigDecimal(v2);   
	  return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();   
	  }
	  
	  //支付接口获取手续费,根据文档 支付方式费率汇总(李林霖20140722).xls,total_fee单位为元,入参：支付接口编码，支付金额，累计支付金额
	@SuppressWarnings("finally")
	public static String getPayPoundage(String pay_code,String single_fee_str,String sum_fee_str) {
		  String result="0";
		  try{
		  double singleFee=Double.valueOf(single_fee_str);
		  BigDecimal single_fee = new BigDecimal(singleFee);
		  if(!"".equals(sum_fee_str)){
			  double sumFee=Double.valueOf(sum_fee_str);
			  BigDecimal sum_fee = new BigDecimal(sumFee);
			  double  d_singleAddSumMoney= PayCommonUtils.add(singleFee, sumFee);
			  BigDecimal singleAddSumMoney=new BigDecimal(d_singleAddSumMoney);
			  
			  //支付宝即时到账接口
			  if(alipay_create_direct.equals(pay_code)){
				  //<=6万
				  if(compare(singleAddSumMoney, 60000)!=1){
					  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_create_direct_1));
				  }
				  //>6万且<=50万
				  else if(compare(singleAddSumMoney, 500000)!=1){
					  //>=6万,直接算
					  if(compare(sum_fee,60000)!=-1){
						  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_create_direct_2));
					  }
					  else{
						  double a1= PayCommonUtils.mul(PayCommonUtils.sub(60000, sumFee), alipay_create_direct_1);
						  double a2= PayCommonUtils.mul(PayCommonUtils.sub(d_singleAddSumMoney, 60000), alipay_create_direct_2);
						  result = String.format(scale, PayCommonUtils.add(a1, a2));
					  }
				  }
				  //>50万且<=100万,(50-6)万
				  else if(compare(singleAddSumMoney, 1000000)!=1){
					  //>=50万,直接算
					  if(compare(sum_fee,500000)!=-1){
						  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_create_direct_3));
					  }
					  else{
						  double a1= PayCommonUtils.mul(PayCommonUtils.sub(500000, sumFee), alipay_create_direct_2);
						  double a2= PayCommonUtils.mul(PayCommonUtils.sub(d_singleAddSumMoney, 500000), alipay_create_direct_3);
						  result = String.format(scale, PayCommonUtils.add(a1, a2));
					  }
				  }
				  //>100万且<=200万
				  else if(compare(singleAddSumMoney, 2000000)!=1){
					  //>=100万,直接算
					  if(compare(sum_fee,1000000)!=-1){
						  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_create_direct_4));
					  }
					  else{
						  double a1= PayCommonUtils.mul(PayCommonUtils.sub(1000000, sumFee), alipay_create_direct_3);
						  double a2= PayCommonUtils.mul(PayCommonUtils.sub(d_singleAddSumMoney, 1000000), alipay_create_direct_4);
						  result = String.format(scale, PayCommonUtils.add(a1, a2));
					  }
				  }
				  //>200万
				  else {
					  //>=200万,直接算
					  if(compare(sum_fee,2000000)!=-1){
						  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_create_direct_5));
					  }
					  else{
						  double a1= PayCommonUtils.mul(PayCommonUtils.sub(2000000, sumFee), alipay_create_direct_4);
						  double a2= PayCommonUtils.mul(PayCommonUtils.sub(d_singleAddSumMoney, 2000000), alipay_create_direct_5);
						  result = String.format(scale, PayCommonUtils.add(a1, a2));
					  }
				  }
			  }
			  //支付宝扫码支付接口
			  else if(alipay_mobile_qrcode.equals(pay_code)){
				  //<=1万
				  if(compare(singleAddSumMoney, 10000)!=1){
					  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_mobile_qrcode_1));
				  }
				  //>1万且<=10万
				  else if(compare(singleAddSumMoney, 100000)!=1){
					  //>=1万,直接算
					  if(compare(sum_fee,10000)!=-1){
						  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_mobile_qrcode_2));
					  }
					  else{
						  double a1= PayCommonUtils.mul(PayCommonUtils.sub(10000, sumFee), alipay_mobile_qrcode_1);
						  double a2= PayCommonUtils.mul(PayCommonUtils.sub(d_singleAddSumMoney, 10000), alipay_mobile_qrcode_2);
						  result = String.format(scale, PayCommonUtils.add(a1, a2));
					  }
				  }
				  //>10万且<=100万,(10-1)万
				  else if(compare(singleAddSumMoney, 1000000)!=1){
					  //>=10万,直接算
					  if(compare(sum_fee,100000)!=-1){
						  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_mobile_qrcode_3));
					  }
					  else{
						  double a1= PayCommonUtils.mul(PayCommonUtils.sub(100000, sumFee), alipay_mobile_qrcode_2);
						  double a2= PayCommonUtils.mul(PayCommonUtils.sub(d_singleAddSumMoney, 100000), alipay_mobile_qrcode_3);
						  result = String.format(scale, PayCommonUtils.add(a1, a2));
					  }
				  }
				  //>100万
				  else {
					  //>=100万,直接算
					  if(compare(sum_fee,1000000)!=-1){
						  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_mobile_qrcode_4));
					  }
					  else{
						  double a1= PayCommonUtils.mul(PayCommonUtils.sub(1000000, sumFee), alipay_mobile_qrcode_3);
						  double a2= PayCommonUtils.mul(PayCommonUtils.sub(d_singleAddSumMoney, 1000000), alipay_mobile_qrcode_4);
						  result = String.format(scale, PayCommonUtils.add(a1, a2));
					  }
				  }
				  
			  }
		  }
		  else{
			  //支付宝无密批量付款到支付宝账支付接口
			   if(alipay_batch_trans_noPwd.equals(pay_code)){
				  //<=2万
				  if(compare(single_fee, 20000)!=1){
					  result =String.valueOf(alipay_batch_trans_noPwd_1); 
				  }
				  //大于2万且<=5万
				  else if(compare(single_fee, 50000)!=1){
					  result =String.valueOf(alipay_batch_trans_noPwd_2); 
				  }
				//大于5万
				  else {
					  result =String.valueOf(alipay_batch_trans_noPwd_3); 
				  }
			  }
			 //微信财付通接口
				  else if(wxpay_create_direct.equals(pay_code)){
					  result = String.format(scale, PayCommonUtils.mul(singleFee, wxpay_create_direct_1));
				  }
				  else if (alipay_BatchTransNoPwd_brokerage.equals(pay_code)){
					  result =String.format(scale, PayCommonUtils.mul(singleFee, alipay_BatchTransNoPwd_brokerage_1));
				  }
			  //银联接口
			  else if(chinaPay.equals(pay_code)){
				  result = String.format(scale, PayCommonUtils.mul(singleFee, chinaPay_1));
			  }
			  //支付宝 手机网页wap版支付  手机网页即时到账接口：需取代原手机网页即时到账接口。费率统一改为单笔交易流量的1%；
			  else if(aliwappay_mobile_create_direct.equals(pay_code)){
				  result = String.format(scale, PayCommonUtils.mul(singleFee, aliwappay_mobile_create_direct_1));
			  }
			 //   即时到账交易接口(create_direct_pay_by_user)：需取代原即时到账交易接口。费率统一改为单笔交易流量的0.8%；
			  else if(alipay_create_direct_new.equals(pay_code)){
				  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_create_direct_new_1));
			  }
			   //     纯网关接口为网银支付接口，后续可酌情使用。费率统一为单笔交易流量的0.3%
			  else if(alipay_pureGateway.equals(pay_code)){
				  result = String.format(scale, PayCommonUtils.mul(singleFee, alipay_pureGateway_1));
			  }
		  }
		  }
		  catch (Exception e) {
			  logger.debug("getPayPoundage-->e:"+e.getMessage()) ;
		  }
		  finally{
			  logger.debug("getPayPoundage-->result:"+result) ;
			  return result;
		  }
	  }
	
	  //将Exception.printStackTrace()转换为String
	  public static String getErrorInfoFromException(Exception e) {  
		  		PrintWriter pw =null;
		         try {  
		        	 StringWriter sw= new StringWriter();  
		               pw = new PrintWriter(sw);  
		              e.printStackTrace(pw); 
		               return sw.toString();  
		         } catch (Exception e2) {  
		               return "bad getErrorInfoFromException";  
		          }
		         finally{
		        	 pw.close();
		        	 pw=null;
		         }
		       }  
	  
	  //获取异常string
	  public static String getLog_error_msg(Exception e,HttpServletResponse response) {
		     String  log_error_msg=getErrorInfoFromException(e);
			 if(log_error_msg.length()>2000)
			 log_error_msg=log_error_msg.substring(0, 1900);
			 /*if(response!=null){
			 response.setContentType("text/html;charset=GBK"); 
	 		 response.getOutputStream().write(errorException.getBytes());
			 }*/
	 		 return log_error_msg;
	  }
	  
	  public static void main(String[] args) {
			System.out.println(String.format(scale, PayCommonUtils.mul(0.4, aliwappay_mobile_create_direct_1)));
	  }

	public static String getJfbCharSet(String char_Set) {
		String charSet = "GBK";
		if ("00".equals(char_Set)) {
			charSet = "GBK";
		} else if ("01".equals(char_Set)) {
			charSet = "GB2312";
		} else if ("02".equals(char_Set)) {
			charSet="UTF-8";
		}
		return charSet;
	}

	
}
